home *** CD-ROM | disk | FTP | other *** search
- !
- ! Default script OBJECT.SCR.
- !
- ! This is the default script for handling objects. It is called whenever
- ! an object is manipulated (Talk, Get, Drop, Wear, Remove, Look, Examine,
- ! Invoke, Use and Exit) under the following conditions:
- !
- ! a) If the object has a script assigned to it, that script is called
- ! first.
- ! b) If the object's script terminates with CONTINUE, or if the object
- ! does not have a script, then this script is called.
- !
- ! You may modify this script at will, but one thing to remember is that
- ! this script should NEVER terminate with CONTINUE. The reason is that
- ! objects may explicitly state that their script is 'OBJECT', in which
- ! case a 'CONTINUE' would execute this script twice! (Once as the script
- ! assigned to the object, and another time because the script ended with
- ! continue).
- !
- ! (c) DC Software, 1992
- !
-
- !------------------------------------------------------------------------!
- :@TALK ! Talk to the object or npc !
- !------------------------------------------------------------------------!
- ! This script is called whenever the object or NPC you tried to talk
- ! to does not have it's own script for handling talking. Thus, it just
- ! prints a standard message. Since nothing really happens here, we
- ! omit the check to see if the player is alive.
-
- ! gosub STILLKICKING; - don't check !
- if npc.count then
- writeln( "The ", npc.type, " has nothing to say.." );
- else
- writeln( "How do you talk to an ", object.type, "?" );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@GET ! Get the object (pick it up) !
- !------------------------------------------------------------------------!
- if npc.count then writeln( "You can't do that.." ); STOP; endif;
- if object.endgame = END_ON_GET then ! Game ends on a GET of this object !
- if object.endtext > 0 then ! .. this text is displayed first.. !
- readtext( object.endtext );
- endif; ! .. then the game ends. !
- ENDGAME;
- endif;
- if object.type = CHEST and object.locktype then ! Locked !
- writeln( "You must first UNLOCK the chest, then GET the gold!" );
- elsif object.type = CHEST or object.type = GOLDSACK then
- if object.value = 0 then
- L(1) = object.count * player.hp * 10 + random( 100 ) + 1;
- else
- L(1) = object.value * object.count;
- if L(1) <= 0 then
- L(1) = object.value;
- endif;
- endif;
- writeln( "Got ", $L1, " (gold pieces)." );
- group.gold = group.gold + L(1);
- vanish( object );
- elsif object.type = FOOD and object.class = 0 then
- writeln( "Got ", object.count, " units of food." );
- group.food = group.food + object.count;
- vanish( object );
- elsif object.weight = 999 then
- writeln( "The ", object.name, " is much too heavy." );
- elsif object.weight = 998 then
- writeln( "The ", object.name, " is can't be moved." );
- elsif object.weight = 997 then
- writeln( "Why would you want to take the ", object.name, "?" );
- elsif object.weight > 255 then
- writeln( "You can't move it!" );
- elsif object.weight > player.mload then
- writeln( "You are not strong enough to carry it!" );
- elsif object.weight > 1 and object.weight + player.load > player.mload then
- writeln( "Your load is too heavy!" );
- elsif object.type = THING then
- writeln( "Please leave the ", object.name, " alone" );
- else
- L(0) = object.count;
- move( object, player.bp ); ! OBJECT does not exist after MOVE !
- if success then
- writeln("Got ", L(0), " ", player.bp.name );
- elsif object.count = L(0) then
- writeln("You couldn't carry it");
- else
- writeln("You could only carry ", L(0) - object.count, " of them." );
- endif;
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@DROP ! Drop the object on the floor !
- !------------------------------------------------------------------------!
- if curritem.count then
- runscript( "CURRITEM", DROP );
- endif;
- if object.count then
- writeln( "DROP has no meaning for an OBJECT not being carried!" );
- else
- writeln( "@DROP entry called in OBJECT script with no OBJECT!" );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@WEAR ! Wear or Wield the object !
- !------------------------------------------------------------------------!
- if curritem.count then
- runscript( "CURRITEM", WEAR );
- endif;
- if object.count then
- writeln( "WEAR has no meaning for an OBJECT not being carried!" );
- else
- writeln( "@WEAR entry called in OBJECT script with no OBJECT!" );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@REMOVE ! Remove an object !
- !------------------------------------------------------------------------!
- if curritem.count then
- runscript( "CURRITEM", REMOVE );
- endif;
- if object.count then
- writeln( "REMOVE has no meaning for an OBJECT not being carried!" );
- else
- writeln( "@REMOVE entry called in OBJECT script with no OBJECT!" );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@LOOK ! Look at an object !
- !------------------------------------------------------------------------!
- L(255) = FALSE; ! Do not give DETAILED description !
- gosub DESCRIBE;
- STOP;
-
- !------------------------------------------------------------------------!
- :@EXAMINE ! Examine the object in detail !
- !------------------------------------------------------------------------!
- L(255) = TRUE; ! Give DETAILED description !
- gosub DESCRIBE;
- STOP;
-
- !------------------------------------------------------------------------!
- :@INVOKE ! Invoke an object we are carrying..
- !------------------------------------------------------------------------!
- if curritem.count then
- runscript( "CURRITEM", INVOKE );
- endif;
- if object.count then
- writeln( "INVOKE has no meaning for an OBJECT not being carried!" );
- else
- writeln( "@INVOKE entry called in OBJECT script with no OBJECT!" );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@USE ! Use an object laying on the ground before us..
- !------------------------------------------------------------------------!
- !
- ! Called when an object that is laying on the ground is 'used'. Note that
- ! 'use' means different things for different object types, and that in
- ! order to invoke an item you have 'get' it and sometimes 'wear' it.
- !
- if object.endgame = END_ON_USE then
- if object.endtext > 0 then ! .. this text is displayed first.. !
- readtext( object.endtext );
- endif; ! .. then the game ends. !
- ENDGAME;
- endif;
-
- ! The CONTROL script checks the distance, so we don't have to
- ! do it here. However, if we wanted to, we could do it like this...
- ! if abs(object.x - player.x) > 1 or abs(object.y - player.y) > 1 then
- ! writeln( "You can't reach the ", object.name );
- ! STOP;
- ! endif;
-
- on object.type goto
- USE_FOOD, USE_WEAPON, USE_AMMO, USE_ARMOR, USE_SHIELD,
- USE_AMULET, USE_RING, USE_POTION, USE_SCROLL, USE_STAFF,
- USE_CHEST, USE_KEYS, USE_GEMS, USE_BOOK, USE_GOLDSACK,
- USE_TORCH, USE_LANTERN, USE_ROPE, USE_HOOKS, USE_MIRROR,
- USE_SIGN, USE_VEHICLE, USE_DOOR, USE_THING;
-
- :USE_THING
- writeln( "I don't know what to do with the ", object.name );
- STOP;
-
- :USE_FOOD
- :USE_POTION
- if object.class then
- writeln( "You must 'get' it, then 'quaff' (eat) it.." );
- else
- writeln( "Just 'get' it.." );
- endif;
- STOP;
-
- :USE_GEMS
- :USE_SCROLL
- writeln( "You must first 'get' it, then 'invoke' it.." );
- STOP;
-
- :USE_AMULET
- :USE_RING
- :USE_ARMOR
- :USE_WEAPON
- :USE_SHIELD
- :USE_STAFF
- writeln( "You must first 'get' it, then 'wear' or 'wield' it.." );
- STOP;
-
- :USE_AMMO
- writeln( "Just carry it in your backpack. If you 'wield' a " );
- writeln( "weapon that uses this type of ammo, it will get used" );
- writeln( "automaticly." );
- STOP;
-
- :USE_CHEST
- ! Unlock the chest !
- if object.locktype then
- gosub UNLOCK_OBJECT;
- if object.locktype = 0 then
- STOP;
- endif;
- writeln( "You don't have the right key! Break the lock?" );
- L0 = select( "Yes", "No" );
- if L0 = 0 then
- if object.class <> NORMAL_DOOR then
- writeln( "You can't break this kind of door." );
- elsif random( 2 + adjustments(player.str) ) > 0 then
- write( "You broke the lock!" );
- if object.traptype = 1 then
- voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
- writeln( "Argh.. Poison trap!" );
- player.poisoned = 1;
- elsif object.traptype > 1 then
- voice( "Explode", 1000 ); ! Play standard sound effect !
- writeln( "Bomb Trap!" );
- dec( player.hp, object.damage );
- if player.hp = 0 then
- writeln( player.name, " has died.." );
- endif;
- endif;
- object.locktype = 0;
- if object.block2 then
- object.block = object.block2;
- endif;
- else
- writeln( "It doesn't break!" );
- endif;
- else
- writeln( "Ok." );
- endif;
- else
- writeln( "It is not locked.." );
- endif;
- stats(-1); ! Restore Statistics !
- STOP;
-
- :USE_KEYS
- writeln( "Just 'Get' it and carry it in case you find a lock that" );
- writeln( "the key can open!" );
- STOP;
-
- :USE_BOOK
- writeln( "To read it, just 'Look' at it.." );
- STOP;
-
- :USE_GOLDSACK
- L(1) = getnum("How many gold pieces do you want to put in it?",
- 0, group.gold / 10) * 10;
- if L(1) then
- writeln( "You put ", $L1, " in the bag." );
- inc( object.value, L(1) );
- dec( group.gold, L(1) );
- else
- writeln( "Smart move.." );
- endif;
- STOP;
-
- :USE_TORCH
- :USE_LANTERN
- writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
- STOP;
-
- :USE_ROPE
- writeln( "After fooling around with it for a while, you manage to" );
- writeln( "get yourself tangled up..." );
- STOP;
-
- :USE_HOOKS
- voice( "Ouch", 1000 );
- writeln( "Ouch! (it's sharp!)" );
- STOP;
-
- :USE_MIRROR
- writeln( "Yes, you are ugly, but that doesn't matter here.." );
- STOP;
-
- :USE_SIGN
- writeln( "It's not yours. You can 'Read' it if you wish.." );
- STOP;
-
- :USE_VEHICLE
- if group.vehicle.count then
- writeln( "You must first exit the one you are in!" );
- STOP;
- endif;
- if object.x <> group.x and object.y <> group.y then
- writeln( "You must be standing next to the ", object.name );
- else
- group.x = object.x; ! Move over to it !
- group.y = object.y;
- move( object, group.vehicle, 1 ); ! Now board the object !
- if success then
- writeln( "You are on riding the ", group.vehicle.name );
- endif;
- endif;
- STOP;
-
- :USE_DOOR
- if object.locktype then ! Door is LOCKED !
- gosub UNLOCK_OBJECT;
- if object.locktype = 0 then ! Done !
- STOP;
- endif;
- writeln( "You don't have the right key! Break the lock?" );
- if getstr( "Yes", "No" ) = 0 then
- if random( 2 + adjustments(player.str) ) > 0 then
- write( "You broke the lock!" );
- if object.traptype = 1 then
- voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
- writeln( "Argh.. Poison trap!" );
- player.poisoned = 1;
- elsif object.traptype > 1 then
- voice( "Explode", 1000 ); ! Play standard sound effect !
- writeln( "Bomb Trap!" );
- dec( player.hp, object.damage );
- if player.hp = 0 then
- writeln( player.name, " has died.." );
- endif;
- endif;
- object.locktype = 0;
- else
- writeln( "It doesn't break!" );
- endif;
- else
- writeln( "Ok." );
- endif;
- else
- writeln( "It is not locked.." );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- :@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
- !------------------------------------------------------------------------!
- if group.vehicle.count = 0 then
- writeln("You are already on foot!" );
- STOP;
- endif;
- drop( group.vehicle );
- voice( "Exit", 1000 );
- writeln( "You are now on foot.." );
- STOP;
-
- !------------------------------------------------------------------------!
- :@ATTACK ! Attack an object or a person !
- !------------------------------------------------------------------------!
- if npc.count then
- if npc.type = HOSTILE then
- FIGHT;
- !- Script ends when you 'FIGHT' -!
- endif;
- writeln( "Find some bad guys to fight!" );
- STOP;
- endif;
- if object.type = CHEST then
- if object.locktype then
- writeln( "Instead of fighting it, try 'UNLOCK'!" );
- else
- writeln( "It's not even locked, why fight it?" );
- endif;
- else
- writeln( "Why would you want to fight the ", object.name );
- endif;
- STOP;
-
- !------------------------------------------------------------------------!
- !-- SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END. THIS IS A CHOICE --!
- !-- NOT A REQUIREMENT. IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE --!
- !-- BIT EASIER TO FOLLOW. ---------------------------------------------!
- !------------------------------------------------------------------------!
-
-
- !------------------------------------------------------------------------!
- ! STILLKICKING: Subroutine to verify that the player is alive before !
- ! allowing him/her/it to perform an action. !
- !------------------------------------------------------------------------!
- :STILLKICKING
- if player.hp = 0 then
- writeln( player.name, " is dead!" );
- STOP;
- endif;
- RETURN;
-
- !------------------------------------------------------------------------!
- !
- ! SUBROUTINE: DESCRIBE
- !
- ! This routine is called from @LOOK, @EXAMINE and by the ANALYZE spell
- ! to describe a given item.
- !
- !------------------------------------------------------------------------!
- :DESCRIBE
- !------------------------------------------------------------------------!
-
- ! First, handle the case where you are looking at a CHARACTER
-
- if npc.count then
- if npc.picture >= 0 then
- viewpcx( npc );
- if success then
- pause;
- endif;
- paint(window); ! Assumes the picture fits in the window, must use !
- ! 'paint(screen)' otherwise !
- endif;
- write( "Name: ", npc.name, ", Type: ", npc.type );
- if npc.type = HOSTILE and npc.weapon.count then
- write( ", Weapon: ", npc.weapon.name, ", Damage: ", npc.weapon.damage, ", Range: ", npc.weapon.range );
- endif;
- if L(255) then
- write( ", Class: ", npc.class, ", Lvl: ", npc.level, ", AC: ", npc.ac, ", HP: ", npc.hp );
- endif;
- writeln(".");
- STOP;
- endif;
- ! Not looking at a character, call the 'DESCOBJ' script to look at an
- ! object.
- runscript( "DESCOBJ", LOOK );
-
- !------------------------------------------------------------------------!
- :UNLOCK_OBJECT
- !------------------------------------------------------------------------!
- L0 = 0;
- :UCLOOP
- setbp( player, L0 );
- if player.bp.count then
- if player.bp.type = KEYS and player.bp.keytype = object.locktype then
- writeln( object.name, " unlocked.." );
- object.locktype = 0;
- if object.block2 then
- object.block = object.block2;
- endif;
- return;
- endif;
- endif;
- inc( L0 );
- if L0 < 16 goto :UCLOOP;
- RETURN;
-
-